package org.example.everyday;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author anlu
 * @date 2022/2/18 11:34
 */
public class LC1791 {

    public int findCenter(int[][] edges) {
        Map<Integer,Integer> map = new HashMap<>();
        int m = edges.length;
        int n = edges[0].length;
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                map.putIfAbsent(edges[i][j],0);
                int res = map.get(edges[i][j]) + 1;
                map.put(edges[i][j], res);
                if(res == m){
                    return edges[i][j];
                }
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[][] nums  = {{1,2},{5,1},{1,3},{1,4}};
        LC1791 lc1791 = new LC1791();
        int result= lc1791.findCenter(nums);
        System.out.println(result);
    }
}
